#ifndef V2_NIM_CONVERSATION_GROUP_SERVICE_H
#define V2_NIM_CONVERSATION_GROUP_SERVICE_H
#include "v2_nim_internal.hpp"
namespace v2 {
/// @brief 会话分组服务
/// @pre
/// 调用 `V2NIMClient::get()` 拿到 client 实例
/// 调用 `client.getConversationgGroupService()` 拿到 conversationGroupService 实例
/// @par 示例代码
/// @code
/// auto& client = V2NIMClient::get();
/// auto& conversationGroupService = client.getConversationgGroupService();
/// @endcode
class V2NIMConversationGroupService {
public:
    /// @brief 创建会话分组
    /// @param name 会话分组名称
    /// @param serverExtension 扩展字段
    /// @param conversationIds 会话 ID 列表
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @par 示例代码
    /// @code
    /// auto conversationIds = nstd::vector<nstd::string>{};
    /// conversationIds.emplace_back(V2NIMConversationIdUtil::p2pConversationId("account1"));
    /// conversationIds.emplace_back(V2NIMConversationIdUtil::teamConversationId("team1"));
    /// conversationGroupService.createConversationGroup(
    ///     "group1",
    ///     "serverExtension",
    ///     conversationIds,
    ///     [](V2NIMConversationGroupResult result) {
    ///         // create conversation group succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // create conversation group failed, handle error
    ///     });
    /// @endcode
    virtual void createConversationGroup(nstd::string name,
        nstd::optional<nstd::string> serverExtension,
        nstd::vector<nstd::string> conversationIds,
        V2NIMSuccessCallback<V2NIMConversationGroupResult> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 删除会话分组
    /// @param groupId 会话分组 ID
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @par 示例代码
    /// @code
    /// conversationGroupService.deleteConversationGroup(
    ///     "groupId",
    ///     []() {
    ///         // delete conversation group succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // delete conversation group failed, handle error
    ///     });
    /// @endcode
    virtual void deleteConversationGroup(nstd::string groupId, V2NIMSuccessCallback<void> success, V2NIMFailureCallback failure) = 0;

    /// @brief 更新会话分组
    /// @param groupId 会话分组 ID
    /// @param name 新的会话分组名称
    /// @param serverExtension 扩展字段
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @par 示例代码
    /// @code
    /// conversationGroupService.updateConversationGroup(
    ///     "groupId",
    ///     "name",
    ///     "serverExtension",
    ///     []() {
    ///         // update conversation group succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // update conversation group failed, handle error
    ///     });
    /// @endcode
    virtual void updateConversationGroup(nstd::string groupId,
        nstd::optional<nstd::string> name,
        nstd::optional<nstd::string> serverExtension,
        V2NIMSuccessCallback<void> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 添加会话到会话分组
    /// @param groupId 会话分组 ID
    /// @param conversationIds 会话 ID 列表
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @par 示例代码
    /// @code
    /// auto conversationIds = nstd::vector<nstd::string>{};
    /// conversationIds.emplace_back(V2NIMConversationIdUtil::p2pConversationId("account1"));
    /// conversationIds.emplace_back(V2NIMConversationIdUtil::teamConversationId("team1"));
    /// conversationGroupService.addConversationsToGroup(
    ///     "groupId",
    ///     conversationIds,
    ///     [](nstd::vector<V2NIMConversationOperationResult> failedList) {
    ///         // add conversations to group succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // add conversations to group failed, handle error
    ///     });
    /// @endcode
    virtual void addConversationsToGroup(nstd::string groupId,
        nstd::vector<nstd::string> conversationIds,
        V2NIMSuccessCallback<nstd::vector<V2NIMConversationOperationResult>> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 从会话分组中移除会话
    /// @param groupId 会话分组 ID
    /// @param conversationIds 会话 ID 列表
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @par 示例代码
    /// @code
    /// auto conversationIds = nstd::vector<nstd::string>{};
    /// conversationIds.emplace_back(V2NIMConversationIdUtil::p2pConversationId("account1"));
    /// conversationIds.emplace_back(V2NIMConversationIdUtil::teamConversationId("team1"));
    /// conversationGroupService.removeConversationsFromGroup(
    ///     "groupId",
    ///     conversationIds,
    ///     [](nstd::vector<V2NIMConversationOperationResult> failedList) {
    ///         // remove conversations from group succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // remove conversations from group failed, handle error
    ///     });
    /// @endcode
    virtual void removeConversationsFromGroup(nstd::string groupId,
        nstd::vector<nstd::string> conversationIds,
        V2NIMSuccessCallback<nstd::vector<V2NIMConversationOperationResult>> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 获取会话分组信息
    /// @param groupId 会话分组 ID
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @par 示例代码
    /// @code
    /// conversationGroupService.getConversationGroup(
    ///     "groupId",
    ///     [](V2NIMConversationGroup group) {
    ///         // get conversation group succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // get conversation group failed, handle error
    ///     });
    /// @endcode
    virtual void getConversationGroup(nstd::string groupId, V2NIMSuccessCallback<V2NIMConversationGroup> success, V2NIMFailureCallback failure) = 0;

    /// @brief 获取会话分组列表
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @par 示例代码
    /// @code
    /// conversationGroupService.getConversationGroupList(
    ///     [](nstd::vector<V2NIMConversationGroup> groupList) {
    ///         // get conversation group list succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // get conversation group list failed, handle error
    ///     });
    /// @endcode
    virtual void getConversationGroupList(V2NIMSuccessCallback<nstd::vector<V2NIMConversationGroup>> success, V2NIMFailureCallback failure) = 0;

    /// @brief 根据会话分组 ID 获取会话分组
    /// @param groupId 会话分组 ID
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @par 示例代码
    /// @code
    /// auto groupIds = nstd::vector<nstd::string>{};
    /// groupIds.emplace_back("groupId1");
    /// groupIds.emplace_back("groupId2");
    /// conversationGroupService.getConversationGroupListByIds(
    ///     groupIds,
    ///     [](nstd::vector<V2NIMConversationGroup> groupList) {
    ///         // get conversation group list by ids succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // get conversation group list by ids failed, handle error
    ///     });
    /// @endcode
    virtual void getConversationGroupListByIds(nstd::vector<nstd::string> groupIds,
        V2NIMSuccessCallback<nstd::vector<V2NIMConversationGroup>> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 添加会话分组监听
    /// @param listener 会话分组监听
    /// @par 示例代码
    /// @code
    /// V2NIMConversationGroupListener listener;
    /// listener.onConversationGroupCreated = [](V2NIMConversationGroup conversationGroup) {
    ///     // handle conversation group created event
    /// };
    /// listener.onConversationGroupDeleted = [](nstd::string groupId) {
    ///     // handle conversation group deleted event
    /// };
    /// listener.onConversationGroupChanged = [](V2NIMConversationGroup conversationGroup) {
    ///     // handle conversation group changed event
    /// };
    /// listener.onConversationsAddedToGroup = [](nstd::string groupId, nstd::vector<V2NIMConversation> conversationList) {
    ///     // handle conversation add to group event
    /// };
    /// listener.onConversationsRemovedFromGroup = [](nstd::string groupId, nstd::vector<nstd::string> conversationIds) {
    ///     // handle conversation remove from group event
    /// };
    /// conversationGroupService.addConversationGroupListener(listener);
    /// @endcode
    virtual void addConversationGroupListener(V2NIMConversationGroupListener listener) = 0;

    /// @brief 移除会话分组监听
    /// @param listener 会话分组监听
    /// @par 示例代码
    /// @code
    /// V2NIMConversationGroupListener listener;
    /// // ...
    /// conversationGroupService.addConversationGroupListener(listener);
    /// // ...
    /// conversationGroupService.removeConversationGroupListener(listener);
    /// @endcode
    virtual void removeConversationGroupListener(V2NIMConversationGroupListener listener) = 0;
};
}  // namespace v2

#endif